using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for KhachHangDAO
/// </summary>
public class KhachHangDAO : SqlDataHelper
{
    private string table;
	public KhachHangDAO()
	{
		//
		// TODO: Add constructor logic here
		//
        this.table = "KhachHang";
	}
    public bool th_KiemTraTenDangNhap(string tendangnhap,string password) {

        string sql;
        DataSet ds;
        try
        {
            sql ="select TenDangNhap from "+ this.table+" where TenDangNhap ='"+ tendangnhap +"' and MatKhau ='"+ password +"'";
            ds = new DataSet();
            ds = this.ExecuteQuery(sql);

            if (ds.Tables[0].Rows.Count > 0)
                return true;
            return false;
        }
        catch 
        {
            return false;
        }

    }
    public bool th_ThemKhachHang(KhachHangPOJO kh) {
        string sql;
        bool check = false;
        DataTable dt;
        try
        {
            sql = "insert into " + this.table;
            sql += "(TenDangNhap,MatKhau,HoTen,TenCongTy,DiaChi,DienThoai,Email) values('";
            sql += kh.Tendangnhap + "','";
            sql += kh.Matkhau + "',N'";
            sql += kh.Hoten + "',N'";
            sql += kh.Tencongty + "',N'";
            sql += kh.Diachi + "','";
            sql += kh.Dienthoai + "','";
            sql += kh.Email + "')";
            check = this.ExecuteNonQuery(sql);
            
            return check;
        }
        catch
        {
            return check;
        }
    }


}
